﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PPI.Entities.Enumerator;
using PPI.General;

namespace PPI.Entities
{
    public class EBaseAssetImage : EBaseImage
    {
        #region Private Properties
        private EBaseAsset m_Asset;
        private EBasePole m_Pole;

        #endregion

        #region Public Members
        public EBaseAsset Asset
        {
            get
            {
                return m_Asset;
            }
            set
            {
                m_Asset = value;
            }
        }
        public EBasePole Pole
        {
            get
            {
                return m_Pole;
            }
            set
            {
                m_Pole = value;
            }
        }

        #endregion

        #region Constructors

        public EBaseAssetImage()
            : base()
        {
            Id = Int32.MinValue;
            m_Asset = new EBaseAsset();
            m_Pole = new EBasePole();
            m_TypeName = PPI.Constants.K_GPSFOLDERNAME;
        }

        public EBaseAssetImage(Int32 id)
            : this()
        {
            Id = id;
        }

        #endregion

        public override string GenerateHTML()
        {
            string htmlImage = "";
            if (this.Asset.DatabaseType == DatabaseTypes.Project)
            {
                ConfigReader reader = ConfigReader.GetInstance();
                string mode = reader.ConectionMode;
                string directoryName = GetDirectoryName(this.Asset.Id);
                string fileName = Asset.Id + "_" + Id;
                htmlImage = "<td><a href=\"#" + GetPlacemarkId() + ";balloon\"><img border='1' src=\"http://www.dev-poleposition.com/Deploy/WebSite2.1/ImagePreview.aspx?Mode=" + mode + "&Type=1&w=" + Constants.k_PREVIEWIMAGEWIDTH + "&h=" + Constants.k_PREVIEWIMAGEHEIGHT + "&fn=" + fileName + "&dn=" + directoryName + "\"></a></td>";
            }
            else
            {
                htmlImage = "<td><a href=\"#" + GetPlacemarkId() + ";balloon\"><img border='1' height=" + Constants.k_PREVIEWIMAGEHEIGHT + " width=" + Constants.k_PREVIEWIMAGEWIDTH + " src=\"" + ImageFile.FullName + "\"></a></td>";
            }
            return htmlImage;
        }
    }
}
